<?php

namespace App\Http\Controllers\api;

use App\Http\Controllers\Controller;
use App\Models\Login;
use Illuminate\Http\Request;

class PayController extends Controller
{
    /**
     * 支付参数
     */
    public function Pay(Request $request){
        //接受参数
       $name=$request->get('name');
        $price=$request->get('price');
        $desc=$request->get('desc');
        $arr[]=$name;
        $arr[]=$price;
        $arr[]=$desc;

        return view('pay/cart',compact('arr'));

    }

    /**
     * 充值
     */
    public function Money(Request  $request){
        //接受用户id
        $userId=$request->get('id');
        //判断用户id
        if(empty($userId) && !is_numeric($userId)){
            return ['code'=>400,'msg'=>'参数错误','data'=>null];
        }

        //根据id 查询相对应的用户余额
       $dataUser= Login::where('id',$userId)->get();
        if($dataUser){
            return  ['code'=>200,'msg'=>'查询成功','data'=>$dataUser];
        }else{
            return  ['code'=>400,'msg'=>'查询失败','data'=>null];
        }

    }
}
